-
Notifications
You must be signed in to change notification settings - Fork 328
Improve _outputFormatter on cache catalog-response to prevent exception
#432
Improve _outputFormatter on cache catalog-response to prevent exception
#432
Conversation
* It is already formatted before it is put into the cache
_outputFormatter from output-cache response_outputFormatter from cache catalog-response to prevent exception
|
Hey! The outputFormatter function does some additional formatting I guess you can test it adding the &response_format=compact as far as I remember. Please make sure it returns the exact same format for the cached and non-cached responses. We need to fix it in storefront-api as well |
|
@pkarw I'm already using the As as I see the processor for the product entity is handling the "decompact" for the response properties in Okay if I compare the output of both requests you can see, the mutated one is landing in the output-cache. First request – uncached: Second request – cached: Could it be a async problem with the process of |
|
Yep, that seems to be it. If I make Would it be better to wait for the output-cache to be written or clone the variable to not slow down the request in case the output-cache Redis or Varnish is blocking the request? – I would choose to create a new clone of the request variable. |
…overwrite the original object that might be written into output-cache
|
Hi Christian, good point! I guess that results in cache should be post-processed by the formatted (to just serve the result HTML in case of Hit). I guess it won't have so much effect (either way you implement it) - so that's fine. |
|
By the way, @cewald would you mind joining the |
|
I've updated the code. I now pass the I still marked the @pkarw I can add this for |
_outputFormatter from cache catalog-response to prevent exception_outputFormatter on cache catalog-response to prevent exception
|
|
|
So we would have to make await in line 156 and in line 151 to be sure that we put in cache always same resBody. Thats not what we want, because we don't want to wait for it. I think that better way is make same aproach as is in storefront-api. Format data before adding to cache. Wdyt? |
|
Yes, we dont need/should to add await for it as we dont need to do anything synchronous after it, indeed. I just added the async to be aware that this is an async function - I can remove it again, but it shouldn‘t affect anything. And to be sure to not save the mutatet version I cloned the But yes, we could do it the same as in the storefront-api and save always the mutated body. Should I change it as it is there? |
|
Yes, please change this as it is in storefront-api. But keep |
… endpoint in cache
|
Okay, done. I also consolidated the double |
gibkigonzo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great :) thanks!
I removed the
_outputFormatterfrom output-cache response in thecatalogendpoint.This change came with this commit: e45bbec.
I'm not sure if this is correct. If I see straight, the output is already formatted before it is put into the cache using the
resultProcessor.In my case, this leads into an exception on each cached request – the first (uncached) works, the second fails with:
This, of course, only appears if
useOutputCacheis enabled.